<script>
  import config from './config'
  import store from '@/store'
  import { getToken } from '@/utils/auth'
  import { geturl, seturl, removeurl } from '@/utils/auth4'
  import { getframe, setframe, removeframe, gettime0, settime0, removetime0 } from '@/utils/auth3'
  
  export default {
    onLaunch: function() {
      this.initApp()
	  let that=this;
	  uni.addInterceptor('navigateTo', {//监听跳转
	  	success(e) {
	  		that.watchRouter(e);
	  	}
	  })
	  uni.addInterceptor('redirectTo', {//监听关闭本页面跳转
	  	success(e) {
	  		that.watchRouter();
	  	}
	  })
	  uni.addInterceptor('switchTab', {//监听tabBar跳转
	  	success(e) {
	  		that.watchRouter();
	  	}
	  })
	  uni.addInterceptor('navigateBack', {//监听返回
	  	success(e) {
	  		that.watchRouter();
	  	}
	  })
    },
    methods: {
		watchRouter(){
			// console.log("路由")
			// if(geturl()){
			// 	if(geturl()!=location.href){
			// 		let time = new Date()
			// 		console.log("newnewnew",time)
			// 		time = time-gettime0()
			// 		setframe(time)
			// 		seturl(location.href)
			// 		settime0(time)
			// 		console.log("geturl()",geturl())
			// 		console.log("gettime0()",gettime0())
			// 		console.log("timewatchRouter",time)
			// 	}
			// }else{
			// 	seturl(location.href)
			// }
			
		},
      // 初始化应用
      initApp() {
        // 初始化应用配置
        this.initConfig()
        // 检查用户登录状态
        //#ifdef H5
        // this.checkLogin()
        //#endif
      },
      initConfig() {
        this.globalData.config = config
      },
      checkLogin() {
        if (!getToken()) {
          this.$tab.reLaunch('/pages/login')
        }
      }
    }
  }
</script>

<style lang="scss">
  @import '@/static/scss/index.scss';
  ::v-deep .el-icon-full-screen:before {
  	display: none;
  }
  ::v-deep .el-icon-zoom-in:before {
  	margin-left: 7vw;
  }
  ::v-deep .el-icon-refresh-left:before {
  	margin-right: 7vw;
  }
</style>
